package com.block.im.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.vo.ResponseVo;
import com.block.im.enums.UserTypeEnum;
import com.block.im.model.dto.IMUserInfoDTO;
import com.block.im.service.IImUserCommonService;
import com.block.im.service.IImUserSigInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ImUserCommonServiceImpl implements IImUserCommonService {

    @Autowired
    IImUserSigInfoService imUserSigInfoService;

    @Override
    public ResponseVo getMemberImUser(Long uid, boolean flushFlag) {

        IMUserInfoDTO imUserInfoDTO = imUserSigInfoService.genUserSig(String.valueOf(uid), UserTypeEnum.USER, flushFlag);

        JSONObject returnObject = new JSONObject();
        returnObject.put("userId", imUserInfoDTO.getUserId());
        returnObject.put("userSig", imUserInfoDTO.getUserSig());

        return new ResponseVo(AppRspCodeConstant.SUCCESS, returnObject);
    }
}
